//
//  YCTextTitleViewCell.m
//  TitleContent
//
//  Created by 唐可雄 on 2019/7/14.
//  Copyright © 2019 swustyc. All rights reserved.
//

#import "YCTextTitleViewCell.h"

@implementation YCTextTitleViewCell

#pragma mark - UICollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self configView];
    }
    return self;
}

#pragma mark - View Config

- (void)configView {
    self.textLabel = [[YCLabel alloc] init];
    self.textLabel.translatesAutoresizingMaskIntoConstraints = NO;
    [self.contentView addSubview:self.textLabel];
    [self.contentView  addConstraint:[NSLayoutConstraint constraintWithItem:self.textLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView  attribute:NSLayoutAttributeTop multiplier:1 constant:0]];
    [self.contentView  addConstraint:[NSLayoutConstraint constraintWithItem:self.textLabel attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:self.contentView  attribute:NSLayoutAttributeLeading multiplier:1 constant:0]];
    [self.contentView  addConstraint:[NSLayoutConstraint constraintWithItem:self.textLabel attribute:NSLayoutAttributeTrailing relatedBy:NSLayoutRelationEqual toItem:self.contentView  attribute:NSLayoutAttributeTrailing multiplier:1 constant:0]];
    [self.contentView  addConstraint:[NSLayoutConstraint constraintWithItem:self.textLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView  attribute:NSLayoutAttributeBottom multiplier:1 constant:0]];
}

#pragma mark - YCTitleViewCell

- (void)configWithSelected:(BOOL)selected {
    self.textLabel.textVerAlignment = self.config.textVerAlignment;
    self.textLabel.textColor = selected ? self.config.textColorSelected : self.config.textColorUnselected;
    self.textLabel.font = selected ? self.config.textFontSelected : self.config.textFontUnselected;
}

- (void)showSelectTransitionWithProgress:(CGFloat)progress {
    self.textLabel.textColor = [UIColor colorTransformFrom:self.config.textColorUnselected to:self.config.textColorSelected progress:progress];
}

- (void)showUnselectTransitionWithProgress:(CGFloat)progress {
    self.textLabel.textColor = [UIColor colorTransformFrom:self.config.textColorSelected to:self.config.textColorUnselected progress:progress];
}

@end
